home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / sql_smts / sql_pub.frm < prev    next >
Text File  |  1994-04-06  |  11KB  |  406 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Dynaset SQL Select on Publishers Name from List box "
  4.    ClientHeight    =   5865
  5.    ClientLeft      =   1560
  6.    ClientTop       =   1410
  7.    ClientWidth     =   6375
  8.    Height          =   6270
  9.    Left            =   1500
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   5865
  12.    ScaleWidth      =   6375
  13.    Top             =   1065
  14.    Width           =   6495
  15.    Begin CommandButton Command4 
  16.       Caption         =   "Push to Not Save Changes"
  17.       Height          =   615
  18.       Left            =   120
  19.       TabIndex        =   21
  20.       Top             =   5040
  21.       Visible         =   0   'False
  22.       Width           =   2415
  23.    End
  24.    Begin CommandButton Command3 
  25.       Caption         =   "Push to Save Changes"
  26.       Height          =   615
  27.       Left            =   3840
  28.       TabIndex        =   11
  29.       Top             =   5040
  30.       Visible         =   0   'False
  31.       Width           =   2415
  32.    End
  33.    Begin TextBox Text8 
  34.       Height          =   375
  35.       Left            =   3840
  36.       TabIndex        =   2
  37.       Top             =   1320
  38.       Width           =   2295
  39.    End
  40.    Begin TextBox Text7 
  41.       Height          =   375
  42.       Left            =   4080
  43.       TabIndex        =   7
  44.       Top             =   2760
  45.       Width           =   2055
  46.    End
  47.    Begin TextBox Text6 
  48.       Height          =   375
  49.       Left            =   4920
  50.       TabIndex        =   5
  51.       Top             =   2040
  52.       Width           =   1215
  53.    End
  54.    Begin TextBox Text5 
  55.       Height          =   375
  56.       Left            =   3240
  57.       TabIndex        =   4
  58.       Top             =   2040
  59.       Width           =   975
  60.    End
  61.    Begin TextBox Text4 
  62.       Height          =   375
  63.       Left            =   720
  64.       TabIndex        =   3
  65.       Top             =   2040
  66.       Width           =   1575
  67.    End
  68.    Begin TextBox Text3 
  69.       Height          =   375
  70.       Left            =   1200
  71.       TabIndex        =   6
  72.       Top             =   2760
  73.       Width           =   1815
  74.    End
  75.    Begin TextBox Text2 
  76.       Height          =   375
  77.       Left            =   1920
  78.       TabIndex        =   8
  79.       Top             =   3480
  80.       Width           =   2295
  81.    End
  82.    Begin ListBox List1 
  83.       Height          =   615
  84.       Left            =   1800
  85.       Sorted          =   -1  'True
  86.       TabIndex        =   0
  87.       Top             =   480
  88.       Width           =   2775
  89.    End
  90.    Begin TextBox Text1 
  91.       Height          =   375
  92.       Left            =   2160
  93.       TabIndex        =   1
  94.       Top             =   1320
  95.       Width           =   735
  96.    End
  97.    Begin CommandButton Command2 
  98.       Caption         =   "Push to make Read/Write"
  99.       Height          =   495
  100.       Left            =   3840
  101.       TabIndex        =   10
  102.       Top             =   4200
  103.       Width           =   2415
  104.    End
  105.    Begin CommandButton Command1 
  106.       Caption         =   "Push to make ReadOnly"
  107.       Height          =   495
  108.       Left            =   120
  109.       TabIndex        =   9
  110.       Top             =   4200
  111.       Width           =   2415
  112.    End
  113.    Begin Label Label10 
  114.       Alignment       =   2  'Center
  115.       AutoSize        =   -1  'True
  116.       Caption         =   "Default is Read/Write"
  117.       FontBold        =   -1  'True
  118.       FontItalic      =   -1  'True
  119.       FontName        =   "MS Sans Serif"
  120.       FontSize        =   9.75
  121.       FontStrikethru  =   0   'False
  122.       FontUnderline   =   0   'False
  123.       Height          =   240
  124.       Left            =   1800
  125.       TabIndex        =   22
  126.       Top             =   0
  127.       Width           =   2355
  128.    End
  129.    Begin Label Label9 
  130.       Caption         =   "Address:"
  131.       Height          =   255
  132.       Left            =   3000
  133.       TabIndex        =   20
  134.       Top             =   1320
  135.       Width           =   735
  136.    End
  137.    Begin Label Label8 
  138.       Caption         =   "Fax:"
  139.       Height          =   255
  140.       Left            =   3480
  141.       TabIndex        =   19
  142.       Top             =   2760
  143.       Width           =   495
  144.    End
  145.    Begin Label Label7 
  146.       Caption         =   "Zip:"
  147.       Height          =   255
  148.       Left            =   4440
  149.       TabIndex        =   18
  150.       Top             =   2040
  151.       Width           =   375
  152.    End
  153.    Begin Label Label6 
  154.       Caption         =   "State:"
  155.       Height          =   255
  156.       Left            =   2520
  157.       TabIndex        =   17
  158.       Top             =   2040
  159.       Width           =   615
  160.    End
  161.    Begin Label Label5 
  162.       Caption         =   "City:"
  163.       Height          =   255
  164.       Left            =   120
  165.       TabIndex        =   16
  166.       Top             =   2040
  167.       Width           =   495
  168.    End
  169.    Begin Label Label4 
  170.       Caption         =   "Company Name:"
  171.       Height          =   255
  172.       Left            =   120
  173.       TabIndex        =   15
  174.       Top             =   3600
  175.       Width           =   1455
  176.    End
  177.    Begin Label Label3 
  178.       Caption         =   "Telephone:"
  179.       Height          =   255
  180.       Left            =   120
  181.       TabIndex        =   14
  182.       Top             =   2760
  183.       Width           =   975
  184.    End
  185.    Begin Label Label2 
  186.       Caption         =   "Select a Publisher's Name from the List ---->"
  187.       Height          =   735
  188.       Left            =   120
  189.       TabIndex        =   13
  190.       Top             =   360
  191.       Width           =   1575
  192.    End
  193.    Begin Label Label1 
  194.       Caption         =   "Publisher Identification:"
  195.       Height          =   255
  196.       Left            =   120
  197.       TabIndex        =   12
  198.       Top             =   1320
  199.       Width           =   2055
  200.    End
  201. End
  202. Option Explicit
  203. Dim readonly_flag%              '** readonly flag var
  204. Dim idx%                        '** index var for combo boxes
  205. Dim a$                          '** holds the string selected from list box
  206. Dim num_recs%                   '** holds the number of records found
  207.  
  208.  
  209. Dim db1 As database             '** database var
  210. Dim ds1 As dynaset              '** dynaset var
  211.  
  212. Sub check_if_readonly (keyascii As Integer)
  213.  
  214.  If keyascii > 0 And readonly_flag% = 1 Then     '** if they press any key and readonly_flag% = 1 then
  215.   keyascii = 0                                   '** turn keystroke off
  216.  Else
  217.   command3.Visible = True
  218.   command4.Visible = True
  219.  End If
  220.  
  221. End Sub
  222.  
  223. Sub Command1_Click ()
  224.  
  225.  readonly_flag% = 1          '*** set readonly_flag% to 1 to makde text boxes readonly
  226.  label10.Caption = "ReadOnly record"
  227.  
  228. End Sub
  229.  
  230. Sub Command2_Click ()
  231.  
  232.  readonly_flag% = 0          '*** set readonly_flag% to 0 to make text boxes read/write
  233.  label10.Caption = "Read/Write record"
  234.  
  235. End Sub
  236.  
  237. Sub Command3_Click ()
  238.  
  239.  label10.Caption = "Changes made to the record, select another record"
  240.  
  241.  Call update_record
  242.  
  243. End Sub
  244.  
  245. Sub Command4_Click ()
  246.  
  247.  list1.SetFocus
  248.  label10.Caption = "No Changes made to the record, re-select same record"
  249.  
  250.  command3.Visible = False
  251.  command4.Visible = False
  252.  label2.Caption = "Select another Publisher's Name from the List ---->"
  253.  
  254. End Sub
  255.  
  256. Sub Form_Load ()
  257.  
  258.  readonly_flag% = 0        '** set default to read/write
  259.  
  260.  Set db1 = OpenDatabase("c:\vb\biblio.mdb", False, True)      '** may need to change path, opened for readonly for list box(faster, list box readonly anyway)
  261.  Set ds1 = db1.CreateDynaset("select name from publishers")   '** bring in all(*) record in the authors table
  262.  
  263.  Do While ds1.EOF = False
  264.   list1.AddItem " " & ds1("name")   '** add publisher names, if null add a space
  265.   ds1.MoveNext
  266.  Loop
  267.  
  268.  ds1.Close
  269.  db1.Close
  270.  
  271.  
  272. End Sub
  273.  
  274. Sub List1_Click ()
  275.  
  276. If readonly_flag% = 1 Then
  277.  label10.Caption = "ReadOnly record"
  278.  Set db1 = OpenDatabase("c:\vb\biblio.mdb", False, True)     '** may need to change path, opened for readonly
  279. Else
  280.  label10.Caption = "Read/Write record"
  281.  Set db1 = OpenDatabase("c:\vb\biblio.mdb")      '** may need to change path, opened for read\write
  282. End If
  283.  
  284.  a$ = Trim$(list1.Li